package br.com.fidalgotecnologia.layar.json;

import org.json.JSONException;
import org.json.JSONObject;

import br.com.fidalgotecnologia.layar.entity.HotSpot;

public class HotSpotJson {
	public static HotSpotJson instance;
	
	public static HotSpotJson getInstance() {
		if(instance==null){
			instance= new HotSpotJson();
		}
		return instance;
	}
	
	public JSONObject toObject(HotSpot hotspot){
		JSONObject hotSpotJson = new JSONObject();
		
		try {
			hotSpotJson.put("id", hotspot.getId());
			hotSpotJson.put("distance", hotspot.getDistance());
			hotSpotJson.put("title", hotspot.getTitle());
			hotSpotJson.put("type", hotspot.getType());
			hotSpotJson.put("lat", hotspot.getLat());
			hotSpotJson.put("lon", hotspot.getLon());
			hotSpotJson.put("actions", ActionJsonArray.getInstance().toArray(hotspot.getActions()));
			hotSpotJson.put("attribution", hotspot.getAttribution());
			hotSpotJson.put("line2",hotspot.getLine2());
			hotSpotJson.put("line3", hotspot.getLine3());
			hotSpotJson.put("line4", hotspot.getLine4());
			hotSpotJson.put("imageURL", hotspot.getImageURL());
			hotSpotJson.put("dimension", hotspot.getDimension());
			hotSpotJson.put("object ", ObjectJson.getInstance().toObject(hotspot.getObject()));
			hotSpotJson.put("transform ", TransformJson.getInstance().toObject(hotspot.getTransform()));
			hotSpotJson.put("alt", hotspot.getAlt());
			hotSpotJson.put("relativeAlt", hotspot.getRelativeAlt());
			hotSpotJson.put("doNotIndex", hotspot.isDoNotIndex());
			hotSpotJson.put("inFocus", hotspot.isInFocus());
			hotSpotJson.put("showSmallBiw", hotspot.isShowSmallBiw());
			hotSpotJson.put("showBiwOnClick", hotspot.isShowBiwOnClick());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return hotSpotJson;
	}
}
